package com.xyang.demo.dao;

import com.github.pagehelper.Page;
import com.xyang.demo.entity.Bxb;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Stars-Of-Future-xYang
 * @version 1.0
 * @date 2021/3/19 10:13
 */

@Mapper
public interface BxbMapper {

    @Select("select * from bxb where is_delete='0'")
    @Results(id = "bxb", value = {
            @Result(column = "id", property = "id", id = true),
            @Result(column = "name", property = "name"),
            @Result(column = "time", property = "time"),
            @Result(column = "price", property = "price"),
            @Result(column = "is_bx", property = "isBx"),
            @Result(column = "is_delete", property = "isDelete")
    })
    List<Bxb> findAll();

    @Insert("insert into bxb(name,time,price,is_bx,is_delete)values(#{name},#{time},#{price},#{isBx},#{isDelete})")
    void add(Bxb bxb);

    @Update("update bxb set name=#{name},time=#{time},price=#{price},is_bx=#{isBx} where id =#{id}")
    void update(Bxb bxb);

    @Select("select * from bxb where id=#{id} and is_delete='0'")
    @ResultMap("bxb")
    Bxb findById(Integer id);

    @Delete("update  bxb set is_delete='1' where id=#{id}")
    void deleteById(Integer id);
}
